package com.njym.java.security.app.biz;

import com.njym.java.security.app.entity.FamilyPhoto;
import com.njym.java.security.app.mapper.FamilyPhotoMapper;
import com.njym.java.security.common.biz.BaseBiz;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 
 *
 * @author lijie
 * @email 717057076@qq.com
 * @date 2019-11-27 16:52:49
 */
@Service
public class FamilyPhotoBiz extends BaseBiz<FamilyPhotoMapper,FamilyPhoto> {

    @Resource
    private FamilyPhotoMapper familyPhotoMapper;

    public List<FamilyPhoto> selectLastWeek(int familyId){
        List<FamilyPhoto> list =  familyPhotoMapper.selectLastWeek(familyId);
        return list;
    }

    public List<FamilyPhoto> selectLastMonth(int familyId){
        List<FamilyPhoto> list =  familyPhotoMapper.selectLastMonth(familyId);
        return list;
    }

    public List<FamilyPhoto> selectMonthAgo(int familyId){
        List<FamilyPhoto> list =  familyPhotoMapper.selectMonthAgo(familyId);
        return list;
    }

    public void addPhotos(int familyId, int addId, String url) {
        FamilyPhoto familyPhoto = new FamilyPhoto();
        familyPhoto.setAddId(addId);
        familyPhoto.setFamilyId(familyId);
        familyPhoto.setUrl(url);
        familyPhoto.setCreateTime(new Date());
        familyPhoto.setDeleted(0);
        familyPhotoMapper.insertSelective(familyPhoto);
    }

    public void deletePhotoById(int id) {
        familyPhotoMapper.deletePhotoById(id);
    }
}